package com.ext.aic.apis.agent;

import android.content.Context;

import androidx.lifecycle.LifecycleOwner;

import com.ext.aic.apis.ApiDefine;
import com.ext.aic.apis.ApiPaths;
import com.ext.aic.apis.RequestResponse;
import com.ext.aic.beans.response.QueryAgentResponse;
import com.ext.aic.beans.response.Response;
import com.hjq.http.EasyHttp;

public class QueryAgentRequest {

    protected void onQueryAgentSuccess(QueryAgentResponse response) {

    }

    public void request(Context context, LifecycleOwner lifecycleOwner, String userId, boolean isShowLoading) {
        EasyHttp.get(lifecycleOwner)
                .api(new ApiDefine(ApiPaths.queryAgent.replace("{userId}", userId)))
                .request(new RequestResponse<Response<QueryAgentResponse>>(context, isShowLoading) {
                    @Override
                    protected void onSuccess(Response<QueryAgentResponse> response) {
                        if (response == null) {
                            return;
                        }
                        if (response.getCode() == 200) {
                            onQueryAgentSuccess(response.getData());
                        }
                    }
                });
    }
}
